<template>
	<view>
		<view class="invoice_list">
			<view class="invoice_item" @click="cahgneC(item)" v-for="(item,index) in myInvoice" :key="index">
				<view class="invoice_item_top">
					<image class="invoice_item_top_image" src="/static/my/clock.png" mode=""></image>
					<text class="invoice_item_top_time">{{item.createTime}}</text>
				</view>
				<view class="invoice_item_bottom">
					<text class="invoice_item_bottom_msg">电子发票</text>
					<text class="invoice_item_bottom_price">{{item.allMoney}}元</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myInvoice:[]
			}
		},
		onLoad(options) {
			console.log(options,'options')
			const { orderId } = options;
			this.invoiceDet(orderId)
		},
		
		methods:{
			invoiceDet(orderId){
				let self = this;
				self._get('user/index/invoice', {orderId}, function(res) {
					const { data } = res;
					self.myInvoice = data;
				});
				
			},
			cahgneC(item){
				uni.navigateTo({
					url:'/userpage/userinfo/invoiceDetail?details='+JSON.stringify(item)
				})
			},
			formDate(date) {
				const dt = new Date(date * 1000)
				const y = dt.getFullYear()
				const m = (dt.getMonth() + 1 + '').padStart(2, '0')
				const d = (dt.getDate() + '').padStart(2, '0')
				const hh = (dt.getHours() + '').padStart(2, '0')
				const mm = (dt.getMinutes() + '').padStart(2, '0')
				const ss = (dt.getSeconds() + '').padStart(2, '0')
			
				return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
			},
		}
	}
</script>

<style lang="less">
	page{
		background-color: #F9F9F9;
	}
	.invoice_list{
		padding: 20rpx 0 0;
	}
	.invoice_item{
		// width: 690rpx;
		// height: 160px;
		padding: 30rpx;
		margin: 0 30rpx 20rpx;
		background: #FFFFFF;
		border-radius: 8rpx;
		.invoice_item_top{
			display: flex;
			align-items: center;
			.invoice_item_top_image{
				width: 28rpx;
				height: 28rpx;
			}
			.invoice_item_top_time{
				margin-left: 20rpx;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #999999;
				line-height: 36rpx;

			}
		}
		.invoice_item_bottom{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 24rpx;
			.invoice_item_bottom_msg{
				// width: 112px;
				// height: 40px;
				font-size: 28rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #333333;
				line-height: 40rpx;

			}
			.invoice_item_bottom_price{
				// width: 150rpx;
				// height: 44rpx;
				font-size: 32rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #333333;
				line-height: 44rpx;

			}
		}
	}
</style>
